<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>
	var ctx="${ctx}";
</script>

<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />

	<link href="${ctx}/static/css/bootstrap.css?v=${static_version}/" rel="stylesheet">
	<link href="${ctx}/static/css/font-awesome.min.css" rel="stylesheet" />
	<link href="${ctx}/static/css/animate.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/style.min.css?v=${static_version}" rel="stylesheet" />
	<link href="${ctx}/static/css/common.css?v=${static_version}" rel="stylesheet" />
	<link href="//at.alicdn.com/t/font_9x03jhokyws9vn29.css" rel="stylesheet">
	<!-- 插件样式  -->
	<link href="${ctx}/static/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
	<link href="${ctx}/static/css/plugins/webuploader/webuploader.css" rel="stylesheet" />
	<link href="${ctx}/static/css/plugins/markdown/bootstrap-markdown.min.css" rel="stylesheet" />
	<link href="${ctx}/static/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
	<link href="${ctx}/static/plugins/region/css/city-picker.css" rel="stylesheet" type="text/css" />
    
</head>

<title>发布新发现需求</title>
<body class="gray-bg">
	<div class="wrapper wrapper-content  animated fadeInRight">
	   	<div class="ibox float-e-margins">
	   	   	<div class="ibox-title">
       			<h5>发布新发现需求<small></small></h5>
	 		</div>
	   		 <div class="ibox-content">
	            <form class="form-group" id="member_table_form" method="post" action="${ctx}/u_requirement_discover-add">	
		            <div class="row">
	            		<div class="form-horizontal">
	            		<div class="form-group">
	                       <input type="hidden" id="id" name="id" value='${u_discover.id}' />
	                           <label class="col-sm-2 control-label" >需求类型：</label>
	
	                           <div class="col-sm-10">
		                           <div class="col-sm-4 m-l-n">
		                               <select name="cateId" class="form-control" >
											<option value="-1">----</option>
											<c:forEach items="${cates}" var="cate">
											<option value="${cate.id}" <c:if test="${cate.id==u_discover.activity_type}">selected</c:if> >${cate.cate_name}</option>
											</c:forEach>
										</select>
									</div>
	                           </div>
	                       </div>           		
	                       	<div class="form-group">
	                       		<input type="hidden" id="id" name="id" value='${u_discover.id}' />
	                           	<label class="col-sm-2 control-label" >需求关键字：</label>	
	                            <div class="col-sm-10">
		                           <div class="col-sm-4 m-l-n">
		                           		<input type="text" class="form-control" value="${u_discover.title}" placeholder="" id="title" name="title" datatype="*" nullmsg="不能为空">
		                           </div>
	                            </div>
	                       </div>
	                       <div class="form-group">
                          	 	<label class="col-sm-2 control-label" >费用预估：</label>
	                           	<div class="col-sm-10">
		                           	<div class="col-sm-4 m-l-n">
		                           		<input type="text" class="form-control" value="${u_discover.average_price}" placeholder="" id="average_price" name="average_price" datatype="*" nullmsg="不能为空">
		                           </div>
	                           </div>
                       		</div>
	                       	                       
	                       <div class="form-group">
	                           <label class="col-sm-2 control-label" >需求起始时间：</label>
	
	                           <div class="col-sm-10">
	                           		<div class="col-sm-4 m-l-n">
		                           		<input type="text" class="input-md form-control layer-date" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="${u_discover.begin_time}" placeholder="起始时间" id="begin_time" name="begin_time" datatype="*" nullmsg="不能为空">
		                           	</div>
	                           </div>
	                       </div>
	                       <div class="form-group">
	                           <label class="col-sm-2 control-label" >需求结束时间：</label>
	
	                           <div class="col-sm-10">
	                           		<div class="col-sm-4 m-l-n">
		                           		<input type="text" class="input-md form-control layer-date" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="${u_discover.end_time}" placeholder="结束时间" id="end_time" name="end_time" datatype="*" nullmsg="不能为空">
		                           	</div>
	                           </div>
	                       </div>
	                       
	                       <div class="form-group">
	                           <label class="col-sm-2 control-label" >需求地址：</label>
	
	                           <div class="col-sm-10">
	                           		<div class="col-sm-4 m-l-n">
		                           		<input id="city-picker3" class="form-control" readonly name="regioninfo" type="text" value="${u_discover.city}" data-toggle="city-picker">
		                           	</div>
	                           </div>
	                       </div>
	                       
	                       <div class="form-group">
	                           <label class="col-sm-2 control-label" >详细地址：</label>
	
	                           <div class="col-sm-10">
	                           		<div class="col-sm-4 m-l-n">
		                           		<input type="text" class="form-control" value="${u_discover.address}" placeholder="" id="address" name="address" datatype="*" nullmsg="不能为空">
		                           	</div>
	                           </div>
	                       </div>
	                     
	                     	<div class="form-group" >
	                       		<input type="hidden" class="form-control" id="head_img" name="head_img" value="${u_discover.head_img}" />
								<label class="col-sm-2 control-label">选择头像：</label>
								<div class="col-sm-10 ">						
										<div  class="col-sm-2 m-l-n">
											<a id="filePicker_covers"><i class="iconfont icon-plus1"></i></a>					
										</div>
										
										<div id="fileList_covers" class="col-sm-2 uploader-list">
										<c:if test="${!empty u_discover.head_img}">
											<img src="${u_discover.head_img}" height="100" border="0" />
										</c:if>
										</div>
										
								</div>					
							</div>
	                       
	                        <div class="form-group">
	                        	<input type="hidden" class="form-control" id="vedio" name="vedio" value="${u_discover.vedio}" />
	                           	<label class="col-sm-2 control-label" >添加音乐：</label>
	                           	<div class="col-sm-10 ">						
									<div  class="col-sm-2 m-l-n">
										<a id="iconbutton"><i class="iconfont icon-plus1"></i></a>					
									</div>									
									<div id="fileList_covers_vedio" class="col-sm-2 uploader-list_vedio">
									<c:if test="${!empty u_discover.vedio}">
										<audio controls='controls'><source src='${u_discover.vedio}' type='audio/mpeg'></audio>
									</c:if>
									</div>										
								</div>	                           
	                        </div>
	                        
	                        
	                       <div class="form-group">
								<label class="col-sm-2 control-label" >需求说明：</label>
								<div class="col-sm-8">
							 		<textarea name="description"  id="description" data-provide="markdown" rows="5" class="textarea"
									placeholder="说点什么...最少输入10个字符" datatype="*0-200" dragonfly="true"
									nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)">${u_discover.description}</textarea>
							 	</div>
						   </div>
						   
	                       <div class="form-group">
								<div class="col-sm-4 col-sm-offset-2">
									<button onClick="u_discover_save_submit();"
										class="btn btn-primary radius" type="submit">
										 保存并提交
									</button>
									&nbsp;&nbsp;
									<button class="btn btn-white" type="button" onclick="layer_close()">
					                           取消</button>
								</div>
							</div>
	                    </div>
		            </div>
	            </form>
				
			</div>
		</div>
	</div>
		
	<script src="${ctx}/static/js/jquery.min.js"></script>
	<script src="${ctx}/static/js/bootstrap.min.js"></script>

	
	<!-- 插件脚本 -->
	<script src="${ctx}/static/js/plugins/layer/layer.js"></script>	
	<script src="${ctx}/static/js/jquery.form.js"></script>
	<script src="${ctx}/static/js/plugins/webuploader/webuploader.min.js"></script>
	<script src="${ctx}/static/js/plugins/validate/jquery.validate.min.js"></script>
	<script src="${ctx}/static/js/Validform/5.3.2/Validform.min.js"></script>
	<script src="${ctx}/static/js/plugins/dataTables/jquery.dataTables.js"></script>
	<script src="${ctx}/static/js/plugins/dataTables/dataTables.bootstrap.js"></script>	
	<script type="text/javascript" src="${ctx}/static/js/plugins/markdown/markdown.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/plugins/markdown/to-markdown.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/plugins/markdown/bootstrap-markdown.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/plugins/markdown/bootstrap-markdown.zh.js"></script>
	<script src="${ctx}/static/js/Validform/5.3.2/Validform.min.js"></script>


	<script type="text/javascript"
		src="${ctx}/static/plugins/region/js/city-picker.data.js"></script>
	<script type="text/javascript"
		src="${ctx}/static/plugins/region/js/city-picker.js"></script>

	<script
		src="${ctx}/static/js/plugins/datapicker/bootstrap-datepicker.js"></script>
	<script src="${ctx}/static/js/My97DatePicker/WdatePicker.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/uthinkjs/discover.js"></script>
	

	
	
<script>
$(document).ready(function(){
	$('#summernote').summernote({   height: 150    });
	$('#charge').find('tbody tr').each(function(){
		var rowIndex = $(this).index() + 1;
		$(this).find('td:eq(0)').text(rowIndex);
		$(this).find('td:eq(4)').find('button').on('click', function(){
			$(this).parent().parent().remove();
			$('#charge').find('tbody tr').each(function(){
				var rowIndex = $(this).index() + 1;
				$(this).find('td:eq(0)').text(rowIndex);
			})
		});
	})	
});

function u_discover_save_submit(){
	document.getElementById("description").value = $('#summernote').summernote('code');
	$("#member_table_form").Validform({
		tiptype:2,
		ajaxPost:true,
		callback:function(form){
			var index = parent.layer.getFrameIndex(window.name);
			if (index){//关闭弹出层
				parent.$('.btn-refresh').click(); 
				parent.layer.close(index);
			}else{//单独的页面
				location.href = "${ctx}/requirement_discover-list"; 
			}
		}
	});
}

$(function() {

	/*外页上传*/
    var $list = $('#fileList_pre_picture'),
        ratio = window.devicePixelRatio || 1,
        thumbnailWidth = 100 * ratio,
        thumbnailHeight = 100 * ratio,
		uploader;

	uploader = WebUploader.create({
        auto: true,
        swf: 'lib/webuploader/0.1.5/Uploader.swf',
        server : '${ctx}/backstage/common/uploadPic',
        pick: '#filePicker_pre_picture',
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
			mimeTypes: 'image/jpg,image/jpeg,image/png'
        },
		formData : {
			foldername : 'discover'
		}
	});

	uploader.on('fileQueued',
		function(file) {
			var $li = $('<div id="' + file.id + '" class="file-item thumbnail">'
					+ '<img>'
					+ '<div class="info">'
					+ file.name + '</div>' + '</div>'), $img = $li
					.find('img');

			$list.append($li);
			uploader.makeThumb(file, function(error, src) {
				if (error) {
					$img.replaceWith('<span>不能预览</span>');
					return;
				}

				$img.attr('src', src);
			}, thumbnailWidth, thumbnailHeight);
		});

	uploader.on('uploadSuccess', function(file, response) {
		$('#' + file.id).addClass('upload-state-done');
		$("#pre_picture").val(response.datas);
	});

	uploader.on('uploadError', function(file) {
		var $li = $('#' + file.id), $error = $li.find('div.error');
		if (!$error.length) {
			$error = $('<div class="error"></div>').appendTo($li);
		}

		$error.text('上传失败');
	});

	uploader.on('uploadComplete', function(file) {
		$('#' + file.id).find('.progress').remove();
	});

});

function add_new_charge() {
	var rowLen = $('#charge').find('tbody tr').length + 1;
	var html = "<tr><td class='col-xs-1'>"
			+ rowLen
			+ "</td><td class='col-xs-3'><input type='text' class='form-control' style='min-width:10px' name='chargenames' datatype='*1-50' nullmsg='不能为空并且不得超过50个字符'></td><td class='col-xs-1'><input type='text' class='form-control' style='min-width:10px' name='chargefees' datatype=' /^{0,1}([0-9]){1,}([.]){0,1}([0-9]){0,}$/i' nullmsg='不能为空并且必须是两位小数或整数'></td><td class='col-xs-2'><input type='text' class='form-control' style='min-width:10px' name='chargelimits' datatype='n1-10' nullmsg='不能为空并且必须是整数'></td><td class='col-xs-1'>"
			+ "<button class='btn btn-warning radius' type='button'><i class='fa fa-remove'>&#xe632;</i> 删除</button></td></tr>";
	$('#charge').find('tbody').append(html);
	$('#charge').find('tbody tr:last').find('button').on('click',
		function() {
		$(this).parent().parent().remove();
		$('#charge').find('tbody tr').each(function() {
			var rowIndex = $(this).index() + 1;
			$(this).find('td:eq(0)').text(rowIndex);
		})
	});
}
</script>
	
</html>